import request from '@/utils/request';

// 统一处理响应
const handleResponse = (response) => {
  if (response.code !== 200) {
    throw new Error(response.message || '获取数据失败');
  }
  return response;
};

/**
 * 获取考试列表
 */
export function getExamList() {
  return request({
    url: '/api/exam/list',
    method: 'get'
  }).then(handleResponse);
}

/**
 * 获取考试详情
 * @param {number} id - 考试ID
 */
export function getExamDetail(id) {
  return request({
    url: `/api/exam/${id}`,
    method: 'get'
  }).then(handleResponse);
} 